<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>会员中心-我的收藏</title>
<link rel="stylesheet" href="__PUBLIC__/Mobile/css/zhanghou.css">
<script src="__PUBLIC__/Mobile/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/Common/Layer/layer.js"></script>
</head>

<body >
<!--账户管理-->
<div class="lm">
	<a href="javascript:history.back(-1);">
		<img src="__PUBLIC__/Mobile/images/return.png" style="height:22px; padding-left:2%; line-height:22px; width:6%; padding-top:2%;" class="left">
	</a>
    <span class="left size20">我的收藏 </span><span style="font-size:1.5em; color:#23CC77;" onClick="empty();">清空</span>
</div>
<section>
	<div class="Collect">
    	<ul>
        	
        	<volist name="result" id="vv">
        		<if condition="$vv['is_type'] eq 1">
		        	<li >
			       	    <img src="__PUBLIC__/Uploads/goods/{$vv.pic_url}" style="width:23%;height:6em;" class="goods" id="{$vv.goods_id}">
			            <span>
			            	<p class="size14">{$vv.detail_title}</p>
			                <!-- <p class="size14">精华本州一次看尽 感悟日本绝...</p>
			                <p class="size14">跟团游</p> -->
			                <p><b class="Orange">￥</b><b class=" Orange size18">{$vv.price_new}</b><b class="gray">元</b></p>
			                <span onclick="del_coll({$vv.id})" style="border:solid 1px #23CC77; width:13%; text-align:center; height:1.6em; line-height:1.6em;">删除</span>
			            </span>
			            <a href="#">
			            	<img src="__PUBLIC__/Mobile/images/car.jpg" width="42" height="42" onClick="add_cart({$vv.goods_id})">
			            </a>
		            </li>
		       <elseif condition="$vv['is_type'] eq 2" />
		        	<li >
			       	    <img src="__PUBLIC__/Uploads/goods/{$vv.pic_url}" style="width:23%;height:6em;" class="goods" id="{$vv.goods_id}">
			            <span>
			            	<p class="size14">{$vv.detail_title}</p>
			                <!-- <p class="size14">精华本州一次看尽 感悟日本绝...</p>-->
			                <p class="size14">跟团游</p> 
			                <p><b class="Orange">￥</b><b class=" Orange size18">{$vv.price_new}</b><b class="gray">元起</b></p>
			                <span onclick="del_coll({$vv.id})" style="border:solid 1px #23CC77; width:13%; text-align:center; height:1.6em; line-height:1.6em;">删除</span>
			            </span>
		            </li>
		       </if>
           </volist>  
        	
        </ul>
    </div>
</section>
<script>
	$(".goods").click(function(){
		var gid = $(this).attr("id");
		$.ajax({
	        type: "POST",
	        url: "{:U('Mycenter/collect_goods')}",
	        data: {gid:gid},
	        dataType: "json",
	        success: function(result){
	         	if(result == '1'){
	         		location.href = "{:U('Goods/goods_goods')}?id="+gid;
	         	}else if(result == '2'){
	         		location.href = "{:U('Tourism/tourism_tourism')}?id="+gid;
	         	}
	         }
	    });
	});
	
	//清空全部记录
	function empty(){
		layer.open({
		    content: '确认要全部清空吗？',
		    btn: ['确认', '取消'],
		    shadeClose: false,
		    style: 'width:80%; height:40%;',
		    yes: function(){
		    	window.location.href = "{:U('Mycenter/empty_collect')}";
		    }
		});
	}
	
	//删除单个
    function del_coll(id){
        $.post("{:U('Mycenter/del_collect')}", { "id": id },
                function(data){
                    if(data==1){
                        layer.msg('删除成功')
                        window.location.href = "{:U('Mycenter/person_collect')}";
                    }else{
                        layer.msg('删除失败');
                    }
        }, "json");
    }

    //添加购物车
    function add_cart(goods_id){
    	var goods_num = 1;
        $.post("{:U('Mycenter/collect_cart')}", {goods_id:goods_id,goods_num:goods_num},function(data){
            if(data == 1){
                layer.alert('成功加入购物车',6);
            }else if(data == 2){
            	layer.alert('请先登录');
                window.location.href="{:U('User/login')}";
            }else{
            	layer.alert('加入购物车失败');
            } 
        },"json");
    }
</script>
</body>
</html>
